#include "ThreadPool(Rebulid).h"

int sum1(int a, int b)
{
	std::this_thread::sleep_for(std::chrono::seconds(3));
	return a + b;
}

int main()
{
	ThreadPool pool;
	//pool.setMode(PoolMode::MODE_CACHED);
	pool.start(2);
	std::future<int> r1 = pool.submitTask(sum1, 1, 2);
	std::future<int> r2 = pool.submitTask(sum1, 1, 2);
	std::future<int> r3 = pool.submitTask(sum1, 1, 2);
	std::future<int> r4 = pool.submitTask([](int s, int e)->int {
		int sum = 0;
		std::this_thread::sleep_for(std::chrono::seconds(3));
		for (int i = s; i <= e; i++)
			sum += i;
		return sum;
		},1,100);
	std::future<int> r5 = pool.submitTask([](int s, int e)->int {
		int sum = 0;
		std::this_thread::sleep_for(std::chrono::seconds(3));
		for (int i = s; i <= e; i++)
			sum += i;
		return sum;
		}, 1, 100);
	printf("%d\n", r1.get());
	printf("%d\n", r2.get());
	printf("%d\n", r3.get());
	printf("%d\n", r4.get());
	printf("%d\n", r5.get());
	return 0;
}